﻿using System;
using NUnit.Framework;

namespace Magellan.Routing.Tests.Unit
{
    [TestFixture]
    public class RouteTests
    {
        [Test]
        public void NameIsRequired()
        {
            Assert.Throws<ArgumentNullException>(() => new Route(null, "/foo", () => null));
            Assert.Throws<ArgumentException>(() => new Route("", "/foo", () => null));
            Assert.Throws<ArgumentException>(() => new Route("  ", "/foo", () => null));
        }

        [Test]
        public void RouteValuesTest()
        {
            var route = new Route("MyRoute", "/blog/{title}", () => null);
            var match = route.MatchPathToRoute("/blog/hello-world");
            Assert.AreEqual(true, match.Success);
            Assert.AreEqual("hello-world", match.Values["title"]);
        }
    }
}
